package command.psicologos;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import model.Psicologo;

import command.ICommand;

import dao.PsicologoDAO;

public class ListarPsicologosCommand implements ICommand{
	
	public String execute(HttpServletRequest request) throws ServletException,IOException {
		PsicologoDAO dao = new PsicologoDAO();
		try {
			ArrayList<Psicologo> psicologos = dao.listar();
			request.setAttribute("psicologos", psicologos);
			return "/paginas/psicologo/listar_psicologo.jsp";
		} catch (SQLException e) {
			e.printStackTrace();
			return "/paginas/tela_principal.jsp";
		}
	}

}
